1 # Building in Windows with MSYS2
3 > **Building with this method is not advised and should be used only if Windows Linux Subsystem can not be used. In all other cases all Windows users should be using Linux Subsystem (WSL) instead**
5 - This environment does not require installing WSL, which may not be available or would get in the way of other virtualization and/or anti-cheat software
6 - It is also much faster to install and get set up because of its small size(~3.65 GB total after building hex file as of 6.0.0)
7 ## Setting up the environment
8 ### Download and install MSYS2
9 1. For 6.0.0, the last version that works is [20220603](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220603.exe)
10 - [20220503](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220503.exe) is also known to work
11 - MSYS2 releases can be viewed at https://repo.msys2.org/distrib/x86_64/
12 - Scroll all the way down for an executable, scroll halfway down for a self-extracting archive
13 1. Open an MSYS2 terminal by running C:\msys64\msys2_shell.cmd
14 1. In the newly opened shell, set up your work path
15 - To paste commands, use "Shift+Insert" or Right-click and select "Paste"
19 ## Downloading and installing dependencies
20 ### Installing other dependencies:
22 pacman -S git ruby make cmake gcc mingw-w64-x86_64-libwinpthread-git unzip wget
24 - Note: If some fails to download, use the following command to install the rest without reinstalling everything:
26 pacman -S git ruby make cmake gcc mingw-w64-x86_64-libwinpthread-git unzip wget --needed
28 ### Download the INAV repository
29 #### Go to the working directory
33 #### Download INAV source code
36 git clone https://github.com/iNavFlight/inav
38 - For [a branch](https://github.com/iNavFlight/inav/branches) or [a tag](https://github.com/iNavFlight/inav/tags):
40 # "release_6.0.0" here can be the name of a branch or a tag
41 git clone --branch release_6.0.0 https://github.com/iNavFlight/inav
43 - If you are internet speed or space restrained, you can also use `--depth 1`, which won't download the whole history, and `--single-branch`, which won't download other branches:
45 git clone --depth 1 --single-branch --branch release_6.0.0 https://github.com/iNavFlight/inav
47 This results in ~302 MB instead of ~468 MB download/install size(as of 6.0.0)
49 1. Create xPack directory:
51 mkdir /c/Workspace/xpack
54 2. Find out which version of xPack you need for your INAV version:
56 # Currently, this is 10.2.1 for 6.0.0 and 10.3.1 for master
57 cat /c/Workspace/inav/cmake/arm-none-eabi-checks.cmake | grep "set(arm_none_eabi_gcc_version" | cut -d\" -f2
59 3. Find the version you need from the [releases page](https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/), then either:
60 - Download the "...-win32-x64.zip" and copy the folder inside, or
61 - Right-click, choose "Copy link address" and paste it into the following commands:
64 # paste the link after "wget"
65 wget https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
66 # paste the file name after "unzip"
67 unzip xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
68 # you can delete the zip file after as it is no longer needed
69 rm xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
71 3. This is important. Put the toolkit first before your path so that it is picked up ahead of any other versions that may be present on your system:
73 export PATH=/c/Workspace/xpack/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin:$PATH
75 ## Building the INAV firmware
76 1. Create the build directory:
78 mkdir /c/Workspace/inav/build
80 2. Go into the build directory:
82 cd /c/Workspace/inav/build
85 - This may take a while. If you only want to test one target, remove the rest of the folders from C:\Workspace\inav\src\main\target\
89 4. Compile the firmware for your flight controller.
93 - The list of available targets in INAV can be found here: https://github.com/inavflight/inav/tree/master/src/main/target
94 - The generated hex file will be in the /c/Workspace/inav/build folder
96 ### *** multiple target patterns. Stop. | Error 2
97 #### Delete everything in the build directory that contains previous runs
98 You can either use file explorer and delete everything inside C:\Workspace\inav\build
101 cd /c/Workspace/inav/build && rm -rf *
103 ### -- could not find arm-none-eabi-gcc
104 #### Redo export PATH, make sure xpack version number is correct:
106 export PATH=/c/Workspace/xpack/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin:$PATH
108 ### make: the '-j' option requires a positive integer argument
109 #### You are using too new version of MSYS2, uninstall and reinstall version [20220603](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220603.exe) or [20220503](https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20220503.exe)